package com.bertie.smiles2iupac;

import java.util.ArrayList;
import java.util.List;

public class Atom {
    private List<Bond> bonds = new ArrayList<Bond>();

    public Atom() {
    }

    public Atom(List<Atom> adjacentAtoms) {
        for (Atom adjacentAtom : adjacentAtoms) {
            bind(this, adjacentAtom);
        }
    }

    private static void bind(Atom a, Atom b) {
        Bond bond = new Bond(a, b);
        a.bonds.add(bond);
        b.bonds.add(bond);
    }

    public List<Bond> getBonds() {
        return new ArrayList<Bond>(bonds);
    }

    public List<Atom> getAdjacentAtoms() {
        List<Atom> adjacentAtoms = new ArrayList<Atom>();
        for (Bond bond : bonds) {
            adjacentAtoms.add(bond.getAtomAtOtherEnd(this));
        }
        return adjacentAtoms;
    }
}
